﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace MengXunAppTool.BLL
{
    public class UIBLL
    {
        private ProgressBar _progressBar;
        private TextBlock _textBlock;
        private Button _button;
        public UIBLL(ProgressBar progressBar, TextBlock textBlock, Button button)
        {
            _progressBar = progressBar;
            _textBlock = textBlock;
            _button = button;
        }
        public void SetBarValue(double value)
        {
            _progressBar.Dispatcher.Invoke((Action)delegate ()
            {
                _progressBar.Value = value;
                _textBlock.Text = value + "%";
            });
        }
        public void AddBarValue(double value)
        {
            _progressBar.Dispatcher.Invoke((Action)delegate ()
            {
                _progressBar.Value += value;
                _textBlock.Text = _progressBar.Value + "%";
            });
        }
        public double GetBarValue()
        {
            double value = 0;
            _progressBar.Dispatcher.Invoke((Action)delegate ()
            {
                value = _progressBar.Value;
            });
            return value;
        }
        public void HideButton()
        {
            _button.Dispatcher.Invoke((Action)delegate ()
            {
                _button.Visibility = Visibility.Hidden;
            });
        }
        public void ShowButton()
        {
            _button.Dispatcher.Invoke((Action)delegate ()
            {
                _button.Visibility = Visibility.Visible;
            });
        }
    }
}
